﻿<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="UploadPopup.aspx.cs" Inherits="Cms.Web.UI.Admin.TinyMCEIntegration.UploadPopup" %>
<%@ Register TagPrefix="neatupload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <base id="baseTag" runat="server" />
    <script type="text/javascript" src="Admin/tiny_mce/tiny_mce_popup.js"></script>
    <link rel="stylesheet" type="text/css" href="Admin/Css/Buttons.css" />		
    <link rel="stylesheet" type="text/css" href="Admin/Css/Dialogs.css" />
    <script language="javascript" src="Admin/Js/CmsLib.js"></script>
    <script language="javascript" src="Admin/Js/Dialogs.js"></script>
    <style type="text/css">
        body 
        {
        	background-color: #f0f0ee; 
        	font-family: Tahoma, Arial, Sans-Serif;
	        font-size: 12px;
        }

        img
        {
	        border: none;
        }

        a, a:hover { color: #444455; }
        h1
        {
	        font-size: 20px;
	        font-weight: normal;
	        color: #000;
        }
        #queuedFiles
        {
        	margin-top: 10px;
        	margin-bottom: 10px;
        	margin-left: 4px;
        	float: left;
        }
        
        #queuedFiles span img, #queuedFiles span span
        {
        	vertical-align: middle;
        }
        
        #queuedFiles span img
        {
        	margin-top: 2px;
        	margin-bottom: 2px;
        }
        
        #progressBar
        {
        	width: 520px;
        	height: 80px;
        	margin-top: -30px;
        }
        
        #overlay
        {
        	display: none;
        	position: absolute;
	        background-color: #ffffff;
            filter:alpha(opacity=70); 
            -moz-opacity: 0.70; 
            opacity: 0.70;
            width: 1px;
            height: 1px;        	
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: right;">
        <asp:LinkButton ID="lbCheckUpload" runat="server" OnClick="lbCheckUpload_Click" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/folder_up.png" alt="" /><span><cms:LocalizedLiteral ID="llUpload" runat="server" /></span></span></span></asp:LinkButton>
        <asp:hyperlink ID="hlCancel" runat="server" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/delete.png" alt="" /><span><cms:LocalizedLiteral ID="llCancel" runat="server" /></span></span></span></asp:hyperlink>
    </div>
    <div id="listContainer" style="margin: 0px; margin-top: 6px; border: 1px solid #919b9c; padding: 10px; background-color: #fff;">
        <div style="margin-bottom: 10px;"><cms:LocalizedLiteral ID="llCurrentFolder" runat="server" />: <asp:Literal ID="litFolder" runat="server" /></div>
        <neatupload:MultiFile id="multiFileId" runat="server" UseFlashIfAvailable="true" FileQueueControlID="queuedFiles">
            <a id="selectFiles" href="#" class="orangeButton"><span><span><img src="Admin/Img/icons/drive_magnify.png" alt="" /><span><cms:LocalizedLiteral ID="llSelectFiles" runat="server" /></span></span></span></a>
        </neatupload:MultiFile>
        <asp:CustomValidator id="valCustom" runat="server" ControlToValidate="multiFileId" ClientValidationFunction="validateFilenames"
            ErrorMessage="" display="None" />
        <div style="display: none; width: 500px; margin-left: 4px; margin-top: 10px;">
            <neatupload:ProgressBar id="progressBar" runat="server" inline="true" />
        </div>

        <div id="queuedFiles"></div>
        <div style="clear: both;"></div>
        
        <div id="overlay"></div>

        <asp:LinkButton ID="lbStartUpload" runat="server" CausesValidation="false" Text="Check" OnClick="lbStartUpload_Click" style="position: absolute; left: -10000px;" />

        <div id="overwriteWarning" style="position: absolute; left: -10000px;">
            <p><cms:LocalizedLiteral ID="llOverwriteMessage" runat="server" />:</p>
            <p><span id="lblExistingFiles"></span></p>
            <p><cms:LocalizedLiteral ID="llOverwriteQuestion" runat="server" /></p>
        </div>

        <iframe id="ifrCheckFiles" runat="server" style="position: absolute; left: -10000px;"></iframe>
    </div>
        
    <script type="text/javascript">
        //<![CDATA[
        function showOverlay() {
            var queuedFiles = document.getElementById("queuedFiles");
            var overlay = document.getElementById("overlay");
            var mainBox = document.getElementById("mainBox");
            var selectFiles = document.getElementById("selectFiles");
            selectFiles.style.display = "none";
            overlay.style.left = iLib.Pos.FindX(queuedFiles) - iLib.Pos.FindX(mainBox) + "px";
            overlay.style.top = iLib.Pos.FindY(queuedFiles) - iLib.Pos.FindY(mainBox) + "px";
            overlay.style.width = queuedFiles.offsetWidth + "px";
            overlay.style.height = queuedFiles.offsetHeight + "px";
            overlay.style.display = "block";
        }

        function handleProgressBar() {
            var progressBar = NeatUploadPB.prototype.Bars["progressBar"];
            var origDisplay = progressBar.Display;
            progressBar.Display = function() {
                var elem = document.getElementById(this.ClientID);
                elem.parentNode.style.display = "block";
                showOverlay();
                origDisplay.call(this);
            }
            progressBar.EvalOnClose = "NeatUploadMainWindow.document.getElementById('" +
		                                progressBar.ClientID + "').parentNode.style.display = \"none\"; NeatUploadMainWindow.document.getElementById(\"overlay\").style.display = \"none\"; NeatUploadMainWindow.document.getElementById(\"selectFiles\").style.display = \"\";";
        }

        // This function is called by the custom validator valCustom
        function validateFilenames(source, args) {
            // Get all selected file spans
            var spans = document.getElementById("queuedFiles").getElementsByTagName("span");
            var selectedFiles = "";
            for (var i = 0; i < spans.length; i++) {
                if (spans[i].parentNode.tagName == "SPAN") {
                    if (selectedFiles != "") {
                        selectedFiles += ",";
                    }
                    selectedFiles += spans[i].innerHTML;
                }
            }
            if (selectedFiles != "") {
                window.frames[1].checkFiles(selectedFiles);
                args.IsValid = false;
            }
            else
                __doPostBack('lbStartUpload', '');
        }

        function validationCallback(status) {
            if (status == "ok") {
                __doPostBack('lbStartUpload', '');
            }
        }

        iLib.Dom.AddListener(window, "load", handleProgressBar);
        //]]>
    </script>
    </form>
</body>
</html>
